package com.watson.juc.single;

import java.lang.reflect.Constructor;

/**
 * @author watson
 * @date 2021/8/2 13:49
 * @Description: TODO
 **/
public enum HolderEnum {
    INSTANCE;

    public HolderEnum getInstance() {
        return INSTANCE;
    }
}

class Test1 {
    public static void main(String[] args) throws Exception {
        HolderEnum instance = HolderEnum.INSTANCE;
        HolderEnum instance2 = HolderEnum.INSTANCE;
        System.out.println(instance);
        System.out.println(instance2);
//        Constructor<HolderEnum> declaredConstructor = HolderEnum.class.getDeclaredConstructor(null);
        Constructor<HolderEnum> declaredConstructor = HolderEnum.class.getDeclaredConstructor(String.class, int.class);
        declaredConstructor.setAccessible(true);
//        HolderEnum instance3 = declaredConstructor.newInstance();
        HolderEnum instance3 = declaredConstructor.newInstance();
        //枚举执行后， class 文件，会形成无参构造
        //再次反编译 ，会得到构造器带两个参数,
    }
}
